fix: retry account bootstrap with modern database relation to accomodate pg_hba not being ready yet#81
Open
jansdhillon wants to merge 2 commits intocanonical:mainfrom
Open
Conversation
…ate pg_hba not being ready yet
There was a problem hiding this comment.
Pull request overview
This PR updates the charm’s admin account bootstrap flow to intentionally fail (and thus re-trigger Juju hook handling) when the initial bootstrap hits the transient Patroni pg_hba.conf race, and adds unit/integration coverage to exercise the retry behavior with the modern database relation.
Changes:
- Raise
CalledProcessErrorfrom_bootstrap_account()when stderr containsno pg_hba.conf entry, enabling hook failure/retry behavior for the transient race. - Restructure
_migrate_schema_bootstrap()so schema failures are handled distinctly, while bootstrap/autoregistration execute after a successful schema update. - Add/repair unit and integration tests to validate bootstrap behavior (including retries) and update an example bundle to configure initial admin credentials.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/charm.py |
Raises on pg_hba race during bootstrap; adjusts schema/bootstrap sequencing. |
tests/unit/test_database_relation.py |
Adds scenario-based unit tests for bootstrap + pg_hba retry behavior during modern DB relation events. |
tests/unit/test_charm.py |
Re-enables and fixes bootstrap-account unit tests; improves call filtering and mocking paths. |
tests/integration/test_bundle.py |
Adds an integration test asserting the admin account exists after modern DB bootstrap completes. |
bundle-examples/internal-haproxy.bundle.yaml |
Configures admin bootstrap fields in the example bundle for end-to-end verification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes https://warthogs.atlassian.net/browse/LNDENG-4035
Run the new integration test:
The bundle has been modified to bootstrap the first admin account:
Using the debug log, observe the behavior when the modern database relation joins:
...
It will (likely) error at first, but the error triggered by the pg_hba failure will trigger the hook to retry, and eventually Patroni will have rendered the pg_hba.conf with the
landscapeuser, and the admin account can be created.You should be able to go to the IP address of the Landscape Server unit and login as
john@example.comwith the passwordpwd.